# coding:UTF-8
# ________________________
# Project_Name:pythonProject
# File_Name:Administrator
# Author:Administrator
# Date_Time:2022/4/22 10:51
# Description:
# ________________________
from selenium import webdriver
import time
from selenium.webdriver.common.by import By



def  foo1():
    driver = webdriver.Chrome()

    driver.maximize_window()

    driver.get(r"C:\PycharmProjects\pythonProject\pyzidonghua\selenium_3\example.html")
    time.sleep(2)
    #先通过name找到alert弹出框
    driver.find_element(By.NAME,("alterbutton")).click()
    time.sleep(2)
    #切换到弹出框，并获取弹出框对象
    alert = driver.switch_to.alert
    #点击确认
    alert.accept()
    time.sleep(2)

    #通过name找到confirm弹出框
    driver.find_element(By.NAME, ("confirmbutton")).click()
    time.sleep(2)
    #切换到弹出框，并获取弹出框对象
    confirm = driver.switch_to.alert
    #点击取消
    confirm.dismiss()
    time.sleep(2)
    #点击确认
    confirm.accept()
    time.sleep(2)

    #通过name找到prompt弹出框
    driver.find_element(By.NAME,("promptbutton")).click()
    time.sleep(2)
    # 切换到弹出框，并获取弹出框对象
    prompt = driver.switch_to.alert
    #输入框输入
    prompt.send_keys("努力学习")
    time.sleep(2)
    #点击确认
    prompt.accept()
    time.sleep(2)
    #点击确认
    prompt.accept()
    time.sleep(1)





    driver.quit()

if  __name__=="__main__":
    foo1()